//转成名字
export function dynamicText(value, options) {
  if (!value) return ''
  if (Array.isArray(value)) {
    if (!options || !Array.isArray(options)) return value.join()
    let textList = []
    for (let i = 0; i < value.length; i++) {
      let item = options.filter(o => o.lineId == value[i])[0]
      if (!item || !item.lineName) {
        textList.push(value[i])
      } else {
        textList.push(item.lineName)
      }
    }
    return textList.join()
  }
  if (!options || !Array.isArray(options)) return value
  let item = options.filter(o => o.lineId == value)[0]
  if (!item || !item.lineName) return value
  return item.lineName
}
//数组拼接
export function dynamicTreeText(value, options) {
	if (!value) return ''

	function transfer(data) {
		let textList = []

		function loop(data, id) {
			for (let i = 0; i < data.length; i++) {
				if (data[i].lineId === id) {
					textList.push(data[i].lineName)
					break
				}
				if (data[i].children) loop(data[i].children, id)
			}
		}
		for (let i = 0; i < data.length; i++) {
			loop(options, data[i])
		}
		return textList.join()
	}
	if (!options || !Array.isArray(options)) return value.join()
	if (Array.isArray(value)) {
		let text = transfer(value)
		return text
	} else {
		if (!options || !Array.isArray(options)) return value
		let list = value.split()
		let text = transfer(list)
		return text
	}
}